class_name WeaponSystem
extends BaseSystem

@export var weapon_item_infos:Array[WeaponItemInfo] = []
var weapon_dict:Dictionary = {}

func create_weapon(weapon_name:String,pos:Vector2) -> Weapon:
	if weapon_dict.has(weapon_name):
		var weapon_item_info:WeaponItemInfo = weapon_dict[weapon_name]
		var weapon:Weapon = GameEffectSystem.create_effect(weapon_item_info.weapon_scene,pos)
		weapon.init_all_weapon_component()
		weapon.discard()
		return weapon
	return null
func get_weapon(weapon_name:String) -> Weapon:
	if weapon_dict.has(weapon_name):
		var weapon_item_info:WeaponItemInfo = weapon_dict[weapon_name]
		var weapon = weapon_item_info.weapon_scene.instantiate()
		weapon.init_all_weapon_component()
		return weapon
	return null
func get_weapon_info(weapon_name:String) -> Resource:
	if weapon_dict.has(weapon_name):
		var weapon_item_info:WeaponItemInfo = weapon_dict[weapon_name]
		return weapon_item_info
	return null

func init_system():
	for weapon_item_info in weapon_item_infos:
		weapon_dict[weapon_item_info.weapon_name] = weapon_item_info
